#include "MainTestFrame.h"
#include "CapyTestLib/TestSuite.h"
#include "CapyTestLib/ImageStore.h"
#include <wx/treectrl.h>
#include <wx/splitter.h>
#include <wx/notebook.h>

enum
{
    ID_Quit = 1,
    ID_About,
};

BEGIN_EVENT_TABLE(MainTestFrame, wxFrame)
    EVT_MENU(ID_Quit,  MainTestFrame::OnQuit)
    EVT_MENU(ID_About, MainTestFrame::OnAbout)
END_EVENT_TABLE()

MainTestFrame::MainTestFrame(
	const wxString& title, const wxPoint& pos, const wxSize& size)
	: wxFrame((wxFrame*)NULL, -1, title, pos, size)
{
	wxMenu *menuFile = new wxMenu;

	menuFile->Append( ID_About, _T("&About Capybara") );
	menuFile->AppendSeparator();
	menuFile->Append( ID_Quit, _T("E&xit") );

	wxMenuBar *menuBar = new wxMenuBar;
	menuBar->Append( menuFile, _T("&File") );

	SetMenuBar( menuBar );

	CreateStatusBar();

	wxSplitterWindow* splitWin = new wxSplitterWindow(this);
	tree = new wxTreeCtrl(splitWin);

	tree->SetImageList(ImageStore::GetTestExplorerImageList());
	
	notebook = new wxNotebook(splitWin, wxID_ANY);

	splitWin->SplitVertically(tree, notebook);
}

void MainTestFrame::OnQuit(wxCommandEvent& WXUNUSED(e))
{
	Close( true );
}

void MainTestFrame::OnAbout(wxCommandEvent& WXUNUSED(e))
{
	wxMessageBox( _T("Capybara Unit Test Framework."),
		_T("About Capybara Test"), wxOK | wxICON_INFORMATION );
}

void MainTestFrame::AddTestSuite(TestSuite& suite)
{
	testSuites.push_back(&suite);
	suite.Draw(*tree, tree->GetRootItem());
}